﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace INSTA.Exercices.Events
{
    class Program
    {
        static void Main(string[] args)
        {            
            // On instancie une classe "Car".
            var car = new Car();

            // On abonne la méthode "car_SpeedChanged" à notre 
            // event "SpeedChanged"..
            car.SpeedChanged += car_SpeedChanged;

            // On fait en sorte que notre event se déclenche..
            car.Accelerate(100);
            car.Brake(10);

        }

        /// <summary>
        /// Handles the SpeedChanged event of the car object.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SpeedChangedEventArgs"/> instance containing the event data.</param>
        private static void car_SpeedChanged(object sender, SpeedChangedEventArgs e)
        {
            Console.WriteLine(e.ToString()); 
        }
    }
}
